<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for src/assets/octopus/engine/request_cookie.js</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="..\..\..\..\prettify.css" />
    <link rel="stylesheet" href="..\..\..\..\base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(..\..\..\..\sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="..\..\..\..\index.html">All files</a> / <a href="index.html">src/assets/octopus/engine</a> request_cookie.js
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>0/13</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>0/2</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>0/4</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>0/13</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">function <span class="fstat-no" title="function not covered" >oRequest_CookieEngine(engine) {</span>
<span class="cstat-no" title="statement not covered" >  this.engine = engine;</span>
<span class="cstat-no" title="statement not covered" >  this.expire = 7;</span>
}
&nbsp;
oRequest_CookieEngine.prototype = {
  get: <span class="fstat-no" title="function not covered" >function (</span>key) {
    // 以下是原生Cookies设置
    // var name = name + "=";
    // var ca = document.cookie.split(';');
    // for (var i = 0; i &lt; ca.length; i++) {
    //   var c = ca[i];
    //   // 循环查找
    //   while (c.charAt(0) == ' ') {
    //     c = c.substring(1);
    //   }
    //   if (c.indexOf(name) != -1) {
    //     return c.substring(name.length, c.length);
    //   }
    // }
&nbsp;
    // 使用vue-cookies解决path问题，原生的cookies函数会绑定你的path，导致在上级path中是获取不到cookies的。
    let value = <span class="cstat-no" title="statement not covered" >this.engine.vue.$cookies.get(key);</span>
<span class="cstat-no" title="statement not covered" >    if (!this.engine.tools.IsNullOrEmpty(value)) {</span>
<span class="cstat-no" title="statement not covered" >      value = this.engine.tools.base64.decode(value);</span>
<span class="cstat-no" title="statement not covered" >      return JSON.parse(value);</span>
    } else {
<span class="cstat-no" title="statement not covered" >      return {};// 如果为空，则返回空。</span>
    }
  },
  // Cookie名字，Cookie值，Cookie过期天数
  set: <span class="fstat-no" title="function not covered" >function (</span>key, value) {
    // 序列化并base64化。
<span class="cstat-no" title="statement not covered" >    value = this.engine.tools.base64.encode(JSON.stringify(value));</span>
&nbsp;
    var d = <span class="cstat-no" title="statement not covered" >new Date();</span>
<span class="cstat-no" title="statement not covered" >    d.setTime(d.getTime() + (this.expire * 24 * 60 * 60 * 1000));</span>
<span class="cstat-no" title="statement not covered" >    this.engine.vue.$cookies.set(key, value, d.toUTCString())</span>
&nbsp;
    // 以下原生的cookies设置会产生作用域的bug，导致通过/跳转以后无法及时获取到，所以得采用vue-cookies的方式来设置。
    // var expires = "expires=" + d.toUTCString();
    // // console.info(name + "=" + value + "; " + expires);
    // document.cookie = name + "=" + value + "; " + expires;
<span class="cstat-no" title="statement not covered" >    return true;</span>
  },
  remove: <span class="fstat-no" title="function not covered" >function (</span>key) {
<span class="cstat-no" title="statement not covered" >    return this.engine.vue.$cookies.remove(key);</span>
  }
}
&nbsp;
export {
  oRequest_CookieEngine
}
&nbsp;
&nbsp;
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jan 20 2020 17:54:15 GMT+0800 (GMT+08:00)
</div>
</div>
<script src="..\..\..\..\prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="..\..\..\..\sorter.js"></script>
</body>
</html>
